<template>
  <el-form :model="form" :rules="rules" :ref="`${refName}_form`">
    <el-form-item prop="userName">
      <input
        style="width: 100%"
        placeholder="用户名"
        class="input"
        clearable
        v-model="form.userName"
      />
    </el-form-item>
    <el-form-item prop="password">
      <div flex="main:justify">
        <input
          class="input"
          type="password"
          show-password
          clearable
          placeholder="请输入密码"
          style="width: 100%"
          v-model="form.password"
        />
      </div>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  props: {
    refName: String,
    isOrgan: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      form: {
        userName: "",
        password: "",
      },
      rules: {
        userName: [{ required: true, message: "请输入用户名" }],
        password: [{ required: true, message: "请输入密码" }],
      },
    };
  },
  methods: {
    submit() {
      let ref = `${this.refName}_form`;

      this.$refs[ref].validate((valid) => {
        if (valid) {
            this.$store.dispatch("user/loginByPassword", this.form).then(()=>{
              this.$router.push('/')
            });
        } else {
          return false;
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.input {
  height: 40px;
  line-height: 40px;
  display: block;
  border-radius: 20px;
  border: 1px solid #e6e6e6;
  color: #808080;
  padding: 0 20px;
}
.input::placeholder,
.input {
  font-size: 16px;
}
</style>